package com.example.xyr.myapplication.utils;

import android.app.Activity;

import com.example.xyr.myapplication.MyApp;
import com.example.xyr.myapplication.model.UserBean;

/**
 * Created by ylcf on 2018/7/26.
 */

public class UserUtils {

    public static void saveUser(UserBean userBean) {
        SPManager.getInstance().putString(MyApp.myapp, "username", userBean.getUsername());
        SPManager.getInstance().putString(MyApp.myapp, "nickname", userBean.getNickname());
        SPManager.getInstance().putString(MyApp.myapp, "avatar", userBean.getAvatar());
        SPManager.getInstance().putString(MyApp.myapp, "address", userBean.getAddress());
        SPManager.getInstance().putBoolean(MyApp.myapp, "isSaveUser", true);
    }

    public static String getUserName() {
        return SPManager.getInstance().getString(MyApp.myapp, "username", "");
    }

    public static String getNickName() {
        return SPManager.getInstance().getString(MyApp.myapp, "nickname", "");
    }

    public static String getAvatar() {
        return SPManager.getInstance().getString(MyApp.myapp, "avatar", "");
    }

    public static boolean isSave(Activity activity) {
        return SPManager.getInstance().getBoolean(activity, "isSaveUser", false);
    }
}
